<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="skins/style.css" rel="stylesheet" type="text/css">
<jsp:include page="/base.jsp"></jsp:include>
</head>
<body>
<%@include file="top.jsp"%>
<table class="yrh">
	<tr>
		<td height="17"><a href="index.jsp">主页</a> &raquo; 新用户注册</td>
	</tr>
</table>
<form action="UserRegisterServlet" method="post" enctype="multipart/form-data" name="form1">
<table class="inputTable">
	<tr>
		<td class="inputTitle">新用户注册</td>
	</tr>
	<tr>
		<td>
		<table class="inputbox">
			<tr>
				<td width="20%" align="right">登录名称：</td>
				<td width="38%"><input type="Text" class="text width100"
					name=userName maxlength="25"></td>
				<td width="41%">&nbsp;<font color="#CC0000">*&nbsp;必输项</font></td>
			</tr>
			<tr>
				<td align="right">登陆账号：</td>
				<td><input type="Text" class="text width100" name="userCode"
					value="" id="userCodeId" maxlength="25"></td>
				<td><font color="#CC0000" id="codeFont">&nbsp; &nbsp;(必填项)</font></td>
			</tr>
			<tr>
				<td align="right">登录密码：</td>
				<td><input type="Password" class="text width100"
					name="userPass" value="" id="passId" maxlength="25"></td>
				<td>&nbsp;<font color="#CC0000">*&nbsp;必输项</font></td>
			</tr>

			<tr>
				<td align="right">密码确认：</td>
				<td><input type="Password" class="text width100"
					name="passConfirm" id="confirmId" maxlength="25"></td>
				<td>&nbsp;<font color="#CC0000" id="confirmSpan">&nbsp;</font></td>
			</tr> 
			<tr>
				<td colspan="3" align="center"><input type="reset" class="bt2"
					value="重置" /> <input type="submit" class="bt2" value="提交"  id="btn_submit"/> <input
					type="button" class="bt2" value="返回"
					onclick="javascript:window.location.href='index.jsp'" /></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</form>
	<%@include file="bottom.jsp"%>
</body>
<script type="text/javascript"  src="jQuery/jquery-3.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#confirmId').on('blur',function(){
		var confirmVal = $(this).val();
		var passVal = $('#passId').val();
		if (confirmVal == passVal) {
			$('#confirmSpan').text("两次密码相同");
		}else{
			$('#btn_submit').on('click',function(){
				return false;
				
			})
			$('#confirmSpan').text("两次密码不同，请重新输入");
		}
	})
})

	$(document).ready(function(){
		$('#userCodeId').on('blur',function(){
			var userCodeVal = $(this).val();
			if (userCodeVal != null && userCodeVal != '') {
				$.ajax({
					type:'get',
					url:'UserCheckCodeServlet',
					data:{'userCode':userCodeVal},
					success:function(result){
						if (result == 1) {
							$('#codeFont').text("该账户可以使用");
						}else{
							$('#btn_submit').on('click',function(){
								return false;
								
							})
							$('#codeFont').text("该账户已经存在，请输入其他账号");
							
						}
					}
				})
			}
		})
	})


</script>
</html>